package designpatterns.strategy;

public class Calculator {
    private BaseAlgorithmStrategy strategy;

    public void setStrategy(BaseAlgorithmStrategy strategy) {
        this.strategy = strategy;
    }

    public int executeStrategy(int a, int b) {
        if (this.strategy == null)
            throw new RuntimeException("请设置算法策略");
        return strategy.execute(a, b);
    }
}
